package com.digital.smartgrow.service.datacenter.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.digital.smartgrow.dto.datacenter.SysDictTypePageDTO;
import com.digital.smartgrow.entity.datacenter.SysDictType;
import com.digital.smartgrow.dao.datacenter.SysDictTypeMapper;
import com.digital.smartgrow.service.datacenter.SysDictTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典类型表 服务实现类
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-11
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {

    @Override
    public Object getListByPage(SysDictTypePageDTO pageDTO) {
        Page<SysDictType> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        QueryWrapper<SysDictType> queryWrapper = new QueryWrapper<>();
        //id
       // queryWrapper.eq(StringUtils.isNotBlank(pageDTO.getDict_id()+""), "dict_id", pageDTO.getDict_id());
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getDict_type()), "dict_type", pageDTO.getDict_type());
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getDict_name()), "dict_name", pageDTO.getDict_name());
        return this.page(page, queryWrapper);
    }

    @Override
    public Object getInfo(Integer id) {
        return this.getById(id);
    }
}
